<?php

namespace app\common\model\user;

use think\Model;


class StudentCertification extends Model
{
    
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    // 定义时间戳字段名
    protected $updateTime = false;
    protected $createTime = 'create_time';

    // 追加属性
    protected $append = [

    ];
    

    
    public function getStatusList()
    {
        return ['1' => __('Status 1'), '2' => __('Status 2'),'3' => __('Status 3'),'4' => __('Status 4'),'4' => __('Status 4'),'5' => __('Status 5')];
    }

    public function getGenderdataList()
    {
        return ['男' => __('男'), '女' => __('女')];
    }

    public function getQualityList()
    {
        return ['1' => __('优'), '2' => __('良')];
    }

    public function getCauseList()
    {   
        $causeModel = new StudentCerticateCause();
        $causeList  = $causeModel->field('id,failure_cause')->select();
        $causeList = collection($causeList)->toArray();
        $array = ['id'=>0,'failure_cause'=>'请选择'];
        array_unshift($causeList, $array);
        return $causeList;
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    /**
     * @return Model|\think\model\relation\BelongsTo
     * 关联用户
     */
    public function user()
    {
        return $this->belongsTo('app\common\model\User', 'user_id','id',[], 'LEFT')->setEagerlyType(1);
    }


    /**
     * @return Model|\think\model\relation\BelongsTo
     * 关联学校
     */
    public function school()
    {
        return $this->belongsTo('app\common\model\School', 'school_id','id',[], 'LEFT')->setEagerlyType(1);
    }



}
